// pages/information/index.js
var util = require('../../utils/util.js');
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    btnLeft:'btn-trade',
    btnRight:'btn-trade',
    trade:'', // 所在行业
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    util.post(app.api.getByUnionid,{unionid:app.globalData.unionid},(res)=>{
      console.log(res,'========================获取详情')
    })
  },

  onShow: function () {
    //获取我的资料
    var that=this;
    if (app.hasLogin()) {
      that.setData({
        userInfo: that.data.userInfo
      });
    } else {
      wx.redirectTo({
        url:"/pages/authorization1/index"
      })
    }
  },
  choseTrade:function(event){
    if(event.target.dataset.id==='left'){
      this.setData({
        btnLeft:"btn-clicked",
        btnRight:"btn-trade",
        trade:'医药'
      })
    }else{
      this.setData({
        btnRight:"btn-clicked",
        btnLeft:"btn-trade",
        trade:'医疗'
      })
    }
  },
  // 点击下一页
  goNextPage: function(){
    var that = this
    if(that.data.trade){
      wx.setStorageSync('info',{trade:that.data.trade})
      wx.navigateTo({
        url: '/pages/information-detail/index',
        // url: '/pages/information-intention/index',
      })
    }else{
      wx.showModal({
        content: '请选择所在行业',
        showCancel: false,
      })
    }
  },
  //分享
  onShareAppMessage: function (res) {
    var that = this
    if (res.from === 'button') {
      // 来自页面内转发按钮
    }
    var title = that.data.positionInfo.companyName + ' 招聘 ' + that.data.positionInfo.name
    return {
      // title: title,
      // path: 'pages/position-detail/position-detail?pid=' + that.data.positionInfo.id,
      // data: that.data.positionInfo,
      imageUrl: this.data.imgUrl,
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      },
    }
  },
  onShareTimeline: function (res) {
    var title = that.data.positionInfo.companyName + ' 招聘 ' + that.data.positionInfo.name
    return {
      title: title,
      query: 'pid=' + that.data.positionInfo.id,
    }
  },
})